﻿<%@ Page Title="Admin - Product Management" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="ProductManagement.aspx.cs" Inherits="ShopFine.Admins.ProductManagement" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        
        function onRequestStart(sender, e) {
            if (e.get_eventTarget().indexOf("ExportToExcelButton") >= 0) {
                e.set_enableAjax(false);
            }
            //var re = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
            //if (e.get_eventTarget().match(re)) {
            if ($("[id*=FileUploadKey]") != null) {
                var fileUpload = $("[id*=FileUploadKey]");
                //AJAX is disabled only if file is selected for upload
                if (fileUpload.value != "") {
                    e.set_enableAjax(false);
                }
            }
            if ($("[id*=FileUpload1]") != null) {
                var fileUpload = $("[id*=FileUpload1]");
                //AJAX is disabled only if file is selected for upload
                if (fileUpload.value != "") {
                    e.set_enableAjax(false);
                }
            }
            if ($("[id*=FileUpload2]") != null) {
                var fileUpload = $("[id*=FileUpload2]");
                //AJAX is disabled only if file is selected for upload
                if (fileUpload.value != "") {
                    e.set_enableAjax(false);
                }
            }
            if ($("[id*=FileUpload3]") != null) {
                var fileUpload = $("[id*=FileUpload3]");
                //AJAX is disabled only if file is selected for upload
                if (fileUpload.value != "") {
                    e.set_enableAjax(false);
                }
            }
            if ($("[id*=FileUpload4]") != null) {
                var fileUpload = $("[id*=FileUpload4]");
                //AJAX is disabled only if file is selected for upload
                if (fileUpload.value != "") {
                    e.set_enableAjax(false);
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="span12">
        <div class="row">
            <div class="product-manager clearfix">
                <div class="titleHeader clearfix">
                    <h3>Product Management</h3>
                </div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <div id="content" style="margin-top: 24px">
                            <telerik:RadCodeBlock ID="DoubleClick" runat="server">
                                <script type="text/javascript">
                                    function RowDblClick(sender, eventArgs) {
                                        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                                    }
                                </script>
                            </telerik:RadCodeBlock>
                            <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="false" Skin="Sunset" />
                            <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
                                EnableRoundedCorners="false" />
                            <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server">
                                <ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
                                <AjaxSettings>
                                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                                        <UpdatedControls>
                                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                                            <telerik:AjaxUpdatedControl ControlID="success"></telerik:AjaxUpdatedControl>
                                            <telerik:AjaxUpdatedControl ControlID="error"></telerik:AjaxUpdatedControl>
                                            <telerik:AjaxUpdatedControl ControlID="RadWindowManager1"></telerik:AjaxUpdatedControl>
                                        </UpdatedControls>
                                    </telerik:AjaxSetting>
                                </AjaxSettings>
                            </telerik:RadAjaxManager>
                            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
                            </telerik:RadAjaxLoadingPanel>
                            <div class="alert alert-block alert-success" id="success" runat="server" visible="false">
                                <asp:Literal ID="ltrSuccess" runat="server"></asp:Literal>
                            </div>
                            <div class="alert alert-block alert-error" id="error" runat="server" visible="false">
                                <asp:Literal ID="ltrError" runat="server"></asp:Literal>
                            </div>
                            <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" PageSize="20"
                                AllowAutomaticUpdates="false" AllowPaging="True" AllowSorting="True" CellSpacing="0"
                                AllowFilteringByColumn="True" FilterMenu-EnableTextHTMLEncoding="True" FilterMenu-AppendDataBoundItems="True"
                                GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource" OnDeleteCommand="RadGrid1_DeleteCommand" OnEditCommand="RadGrid1_EditCommand" OnInsertCommand="RadGrid1_InsertCommand" OnItemCommand="RadGrid1_ItemCommand" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound" OnUpdateCommand="RadGrid1_UpdateCommand">
                                <ClientSettings>
                                    <Selecting AllowRowSelect="true"></Selecting>
                                    <Scrolling AllowScroll="True" ScrollHeight="400px" UseStaticHeaders="true" FrozenColumnsCount="2"></Scrolling>
                                    <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
                                </ClientSettings>
                                <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID"
                                    InsertItemPageIndexAction="ShowItemOnFirstPage" EditMode="EditForms" TableLayout="Fixed">
                                    <CommandItemSettings ExportToPdfText="Export to PDF" ShowExportToExcelButton="True"
                                        ShowAddNewRecordButton="True"></CommandItemSettings>
                                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>
                                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </ExpandCollapseColumn>
                                    <Columns>
                                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="Edit" CancelText="Cancel" UpdateText="Save Changes">
                                            <HeaderStyle Width="35px" />
                                            <ItemStyle Width="35px" />
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Del" ConfirmTitle="Confirmation" ConfirmDialogType="RadWindow" ConfirmTextFormatString="Are you sure wanna delete product:'{0}'?"
                                            ConfirmTextFields="Name" CommandName="Delete" ConfirmDialogWidth="350px" ConfirmDialogHeight="140px">
                                            <HeaderStyle Width="35px" />
                                            <ItemStyle Width="35px" />
                                        </telerik:GridButtonColumn>
                                        <telerik:GridBoundColumn DataField="ProductCode"
                                            HeaderText="ProductCode" SortExpression="ProductCode" UniqueName="ProductCode">
                                            <HeaderStyle Width="100px" />
                                            <ItemStyle Width="100px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Name"
                                            HeaderText="Title" SortExpression="Name" UniqueName="Name">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Price" AllowFiltering="false"
                                            HeaderText="Price" SortExpression="Price" UniqueName="Price" DataFormatString="{0:$#,##0}">
                                            <HeaderStyle Width="80px" />
                                            <ItemStyle Width="80px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Description" AllowFiltering="false"
                                            HeaderText="Description" SortExpression="Description" UniqueName="Description">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="SupplierName" AllowFiltering="false"
                                            HeaderText="Supplier" SortExpression="SupplierName" UniqueName="SupplierName">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="SubCategoryName" AllowFiltering="false"
                                            HeaderText="SubCategory" SortExpression="SubCategoryName" UniqueName="SubCategoryName">
                                            <HeaderStyle Width="120px" />
                                            <ItemStyle Width="120px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImageUrl" AllowFiltering="false"
                                            HeaderText="Display Image" SortExpression="ImageUrl" UniqueName="ImageUrl">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImageUrl1" AllowFiltering="false"
                                            HeaderText="Image 1" SortExpression="ImageUrl1" UniqueName="ImageUrl1">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImageUrl2" AllowFiltering="false"
                                            HeaderText="Image 2" SortExpression="ImageUrl2" UniqueName="ImageUrl2">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImageUrl3" AllowFiltering="false"
                                            HeaderText="Image 3" SortExpression="ImageUrl3" UniqueName="ImageUrl3">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImageUrl4" AllowFiltering="false"
                                            HeaderText="Image 4" SortExpression="ImageUrl4" UniqueName="ImageUrl4">
                                            <HeaderStyle Width="150px" />
                                            <ItemStyle Width="150px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="CreateDate" AllowFiltering="false"
                                            HeaderText="CreateDate" SortExpression="CreateDate" UniqueName="CreateDate" DataFormatString="{0: dd/MM/yyyy}">
                                            <HeaderStyle Width="80px" />
                                            <ItemStyle Width="80px" />
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                    <EditFormSettings UserControlName="~/userControls/UcEditProduct.ascx" EditFormType="WebUserControl" InsertCaption="Add new product" CaptionFormatString="Edit Product: {0}" CaptionDataField="ID">
                                        <%--<PopUpSettings Modal="True" Width="900px" Height="550px"></PopUpSettings>--%>
                                    </EditFormSettings>
                                </MasterTableView>
                                <ValidationSettings CommandsToValidate="PerformInsert,Update" />
                                <FilterMenu EnableImageSprites="False">
                                </FilterMenu>
                            </telerik:RadGrid>
                            <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                            </telerik:RadWindowManager>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
</asp:Content>
